<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('offering')} > ${i18n.getMessage('attendance')}">
	<a href="#" onclick="cc('offering/showEditAttendance.sgt?offeringId=${model.offering.id}')">${i18n.getMessage('check')}</a>
	- <a href="#" onclick="pp('offering/showReportAttendance.sgt?offeringId=${model.offering.id}')">${i18n.getMessage('reportAll')}</a>
	- <a href="#" onclick="cc('offering/showReportAttendanceForm.sgt?offeringId=${model.offering.id}')">${i18n.getMessage('report')}</a>
	- <a href="#" onclick="cc('offering/showInfoOffering.sgt?id=${model.offering.id}')">${i18n.getMessage('offering')}</a>
</@showTitle>

<br/>

<#macro formatOn status>
	<#if status == "A">
		;background-color:yellow
	</#if>
</#macro>

<div style="overflow:auto">

<table border="1" cellspacing="0" cellpadding=0" class="default">
	<tr style="text-align:center; font-weight:bold; background-color:#04aa9c; color:#FFF; font-size: 11px; padding:2px">
		<td rowspan="2" style="text-align:center; width:20px">${i18n.getMessage('ordinalNumber')}</td>
		<td rowspan="2" colspan="2">${i18n.getMessage('fullName')}</td>
		<td rowspan="2">${i18n.getMessage('dateOfBirth')}</td>
		<td rowspan="2">${i18n.getMessage('absence')}</td>
		<#list model.months as month>
			<td colspan="${model.getDays(month)}">${month}</td>
		</#list>
	</th>
	<tr style="text-align:center; background-color:#04aa9c; color:#FFF; padding:2px">
		<#list model.days as day>
			<td style="width:20px;height:20px">${day?string('d')}</td>
		</#list>
	</tr>
	
	<#assign memberCount = (model.offering.members.size())!>
	<#list model.offeringMembers as member>
		<tr <#if ((member_index % 2) = 0)>style="background-color:#DEDEDE"<#else>style="background-color:#FFF"</#if>>
			<td class="center" style="border: solid 1px #FFF;">${(member_index + 1)!}</td>
			<td style="border: solid 1px #FFF;"><#if (member.active)>${(member.receipt.student.lastName)!}<#else><span style="text-decoration: line-through">${(member.receipt.student.lastName)!}</span></#if></td>
			<td style="border: solid 1px #FFF;"><#if (member.active)>${(member.receipt.student.firstName)!}<#else><span style="text-decoration: line-through">${(member.receipt.student.firstName)!}</span></#if></td>
			<td style="border: solid 1px #FFF;">${(member.receipt.student.dateOfBirth?date)!}</td>
			<td class="center" style="border: solid 1px #FFF;">${(member.absentAttendances.size())!}</td>
			<#list model.days as day>
				<#assign s = model.interrupted(day)>
				<#if s == 1>
					<#if member_index == 0>
						<td rowspan="${model.offeringMembers.size()}" style="font-weight:bold;text-align:center;border: solid 1px #FFF">C<br/>A<br/>N<br/>C<br/>E<br/>L</td>
					</#if>
				<#elseif s == 2>
					<#if member_index == 0>
						<td rowspan="${model.offeringMembers.size()}" style="font-weight:bold;text-align:center;border: solid 1px #FFF">H<br/>O<br/>L<br/>I<br/>D<br/>A<br/>Y</td>
					</#if>
				<#else>
					<td onclick="cc('offering/showEditAttendance.sgt?offeringId=${model.offering.id}&memberId=${member.id}&date=${day?date}')" 
					style="text-align:center; border: solid 1px #FFF; padding-left:3px; cursor:pointer
					<@formatOn (i18n.getMessage(member.getAttendance(day).status.key))!'&nbsp;'/>">
						${(i18n.getMessage(member.getAttendance(day).status.key))!'&nbsp;'}
					</td>
				</#if>
			</#list>
		</tr>
	</#list>
	
</table>

</div>

<br/>